package com.example.moblie2021606143cwj0509;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnLiuliang;
    private TextView tvMainResult;
    private Button btnMainOk;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnLiuliang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,PartActivity.class);
                startActivityForResult(intent,1);
            }
        });
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == RESULT_OK) {
            tvMainResult.setText(data.getStringExtra("Part"));
        }
    }

    private void initView() {
        tvMainTitle = findViewById(R.id.tv_main_title);
        btnLiuliang = findViewById(R.id.btn_liuliang);
        tvMainResult = findViewById(R.id.tvMainResult);
        btnMainOk = findViewById(R.id.btn_main_ok);
    }
}